-
Notifications
You must be signed in to change notification settings - Fork 50
Feat: check if system has creds saved, add new messages, extend backendSystem #3720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat: check if system has creds saved, add new messages, extend backendSystem #3720
Conversation
🦋 Changeset detectedLatest commit: 7960995 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikicvi-SAP, here are my suggestions.
packages/fiori-app-sub-generator/src/translations/fioriAppSubGenerator.i18n.json
Outdated
Show resolved
Hide resolved
packages/fiori-app-sub-generator/src/translations/fioriAppSubGenerator.i18n.json
Outdated
Show resolved
Hide resolved
packages/odata-service-inquirer/src/translations/odata-service-inquirer.i18n.json
Outdated
Show resolved
Hide resolved
packages/odata-service-inquirer/src/translations/odata-service-inquirer.i18n.json
Show resolved
Hide resolved
packages/odata-service-inquirer/src/translations/odata-service-inquirer.i18n.json
Outdated
Show resolved
Hide resolved
| // No need to await, we cannot recover anyway | ||
| // eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
| storeService.write(service.backendSystem); | ||
| } else if (service.backendSystem?.newOrUpdated === false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this condition should be inside (service.backendSystem && hostEnv !== hostEnvironment.bas) otherwise it will always log, even on bas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense - thank you. Committed, with an additional check, as discussed.
…ithout-credentials
…s, enhance handling for temp creds, pre-fill username
…rwriting-saved-system-without-credentials
| service.backendSystem && | ||
| hostEnv !== hostEnvironment.bas && | ||
| service.backendSystem.newOrUpdated && | ||
| !service.backendSystem.temporaryCredentials |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not remove the credentials from the PromptState.odataService.backendSystem object before returning (wherever we determine this) - so we dont need this extra logic in multiple places? I dont recall why we need this extra property temporaryCredentials?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could do it with just newOrUpdated, actually, without the temporaryCredentials.
| ); | ||
| (backendSystem as BackendSystemSelection).hasStoredCredentials = true; | ||
| return true; | ||
| } else if (errorType === ERROR_TYPE.AUTH && !hasStoredCredentials) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this condition? Regardless of having creds or auth fails and the user will have to input credentials.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed - leftover from testing something during dev, will remove it - thanks for spotting!
| systemChoices = await Promise.all( | ||
| backendSystems.map(async (system) => { | ||
| // Check if the system has stored credentials by reading it with sensitive data | ||
| const systemWithCredentials = await new SystemService(LoggerHelper.logger).read( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reading every system from secure store? We went to some effort to avoid this!
…rwriting-saved-system-without-credentials
|
| const selectedSystem = answers?.[promptNames.systemSelection] as SystemSelectionAnswerType; | ||
| if (selectedSystem?.type === 'backendSystem') { | ||
| const selectedBackendSystem = selectedSystem.system as BackendSystem; | ||
| if (selectedBackendSystem?.userDisplayName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why check for display name here? I dont think this is related to the username.
| return valResult; | ||
| }, | ||
| additionalMessages: (password: string, answers: T) => { | ||
| if (PromptState.odataService.connectedSystem?.backendSystem?.newOrUpdated) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a lower priority that the cert errors (the condition should be evaluated after error conditions)
| ); | ||
| } else if (backendSystem.authenticationType === 'basic' || !backendSystem.authenticationType) { | ||
| const hasStoredCredentials = !!(backendSystem.username && backendSystem.password); | ||
| PromptState.hasStoredCredentials = hasStoredCredentials; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not sure we should be maintaining a specific system info at the root level without context. Can we instead update the locally cached backend system (selected system actually) that is selected with updateCredentials boolean property that is set based on some criteria (existence of credentials or a property of the stored system in future marked as do not store creds).
| const selectedBackendSystem = selectedSystem.system as BackendSystem; | ||
| if (selectedBackendSystem?.userDisplayName) { | ||
| // Read system with credentials to get the stored username, since we won't assume that displayName = username | ||
| const systemWithCredentials = await new SystemService(LoggerHelper.logger).read( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can avoid a second read here.
| typeof backendSystem.username === 'string' && | ||
| typeof backendSystem.password === 'string' | ||
| ) { | ||
| if (errorType === ERROR_TYPE.AUTH) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldnt be validating if there are no credentials to validate hence the conditions that have been removed? Note that this code is also used by new system flows probably and so these conditions are relevant in those cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was meant to check with hasStoredCredentials from above, which would be valid at that point. I missed it.



#3718